package com.github.niefy.modules.wx.manage;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.niefy.common.utils.R;
import com.github.niefy.modules.wx.entity.Message;
import com.github.niefy.modules.wx.service.MessageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Map;

/**
 * @Description:
 * @Company：乙盟信息
 * @Author: jiangheng
 * @Date: 2022/2/26 16:16
 * @Version 1.0
 */
@RestController
@RequestMapping("/manage/message")
public class MessageController {
    @Resource
    private MessageService messageService;

    @GetMapping("list")
    public R list(@RequestParam Map<String, Object> params) {
        IPage<Message> page=new Page<Message>(Integer.parseInt(params.get("page").toString()) , Integer.parseInt(params.get("limit").toString()));
        IPage<Message> all = messageService.queryPage(page,params);
        return R.ok().put("page", page);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    public R delete(@RequestBody String[] ids) {
        messageService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}
